$Id$

Instructions for building SA-POP Federate
  03/18/2009 Revision (John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>)
  03/20/2009 Revision (Daniel L.C. Mack <daniel.l.mack@vanderbilt.edu>)


ACE:
(http://www.cs.wustl.edu/~schmidt/ACE_wrappers/ACE-INSTALL.html)
-Install and set environment variables for:
  -Microsoft Visual Studio 2005 Professional [install]
  -ActiveState ActivePerl (e.g., 5.8.8.820-MSWin32-x86-274739 or later) [install]
  -Xerces-C (version 2.8.0-win32-vc8) [extract pre-built (e.g. to C:/Program Files/Xerces) & set env. vars.]
    set XERCESCROOT=C:/Program Files/Xerces/xerces-c_2_8_0-x86-windows-vc_8_0
    set Path=%XERCESCROOT%/bin;%XERCESCROOT%/lib;%PATH%
-FIRST TIME:
  -Download "Sources only" for a release/micro-release from http://download.dre.vanderbilt.edu/
  -Extract (e.g. to C:\Middleware\X_Y_Z for version X.Y.Z so %ACE_ROOT% would be C:\Middleware\X_Y_Z\ACE_wrappers)
-Set ACE environment variables (global environment or in batch file before compiling and before running)
  set ACE_ROOT=C:/Middleware/X_Y_Z/ACE_wrappers
  set Path=%ACE_ROOT%/bin;%ACE_ROOT%/lib;%PATH%
-FIRST TIME:
  -Set ACE config file in %ACE_ROOT%\ace
    cd %ACE_ROOT%\ace
    -create config.h and in it, add the line: #include "ace/config-win32.h"
  -Set Make Project Creator default configuration in %ACE_ROOT%\bin\MakeProjectCreator\config\
    cd %ACE_ROOT%\bin\MakeProjectCreator\config\
    copy global.features default.features
-Build ACE
  -Generate (or regenerate) MSVC++ projects and solution.
    cd %ACE_ROOT%
    perl %ACE_ROOT%\bin\mwc.pl -type vc8 ACE.mwc
  -Open ACE.sln and build solution (in MSVC++)
    devenv /build "Debug|Win32" ACE.sln



SA-POP Core:
-Install, build if necessary, and set environment variables for:
  -Microsoft Visual Studio 2005 Professional [install]
  -ActiveState ActivePerl (e.g., 5.8.8.820-MSWin32-x86-274739 or later) [install]
  -Subversion (e.g., 1.4.3-r23084 or later) [install]
  -Xerces-C (e.g., 2.7.0-win32-vc8 or 2.8.0-win32-vc8) [install pre-built & set env. vars.]
  -ACE [build & set env. vars.]
  -Graphviz(http://www.graphviz.org/Download..php),
     -Install latest version (X.YZ) in program files, then set the path for the bin folder like so:
     -set Path=C:\Program Files\GraphvizX.YZ\Bin;%PATH%
-FIRST TIME
  -Checkout SA-POP (can be placed anywhere; example is under C:\C2W so %SAPOP_ROOT% would be C:\C2W\SA_POP)
    cd \C2W
    svn co https://svn.dre.vanderbilt.edu/DOC/Middleware/branches/RACE_devl/SA_POP SA_POP
-Set SA-POP environment variables:
  set SAPOP_ROOT=C:/C2W/SA_POP
  set SANET_ROOT=%SAPOP_ROOT%/SANet
  set path=%SAPOP_ROOT%/lib;%PATH%
-Generate (or regenerate) MSVC++ projects and solution.
  cd %SAPOP_ROOT%
  perl %ACE_ROOT%\bin\mwc.pl -type vc8 SAPOP_Standalone.mwc
-Open SAPOP_Standalone.sln and build solution (in MSVC++)
  devenv /build "Debug|Win32" SAPOP_Standalone.sln


inputFed Federate:
-Run %C2WTROOT%\src\cpp\demoSAPOP\inputFed\inputFed.sln file. 
-Compile release version.

SA-POP Federate:

-Generate the code from demoSAPOP model in %C2WTROOT%\src\models\demoSAPOP
-Generate the deployment scripts from demoSAPOP model in %C2WTROOT%\src\models\demoSAPOP
-If you haven't made the environment variables for SA-POP and ACe global, you need to include them at the top of the deployment script in :
	%C2WTROOT%\generated\scripts\demoSAPOP
-Generate (or regenerate) MSVC++ projects and solution.
  cd %C2WTROOT%\src\cpp\demoSAPOP\SAPOP
  perl %ACE_ROOT%\bin\mpc.pl -type vc8 SAPOPFed.mpc

-Run SAPOPFed.sln file. Compile Debug version.


Running the Demo:
The Demo is a small federation. There is an input federate and then the SA-POP federate. The inputFed takes as input a script.  The script is a newline delimited file of time slices, and conditions to activate as either true or false(1 == true, 0 == false). Look in the  %C2WTROOT%\src\cpp\demoSAPOP\inputFed for two example scripts. To run one, recompile the federate with the absolute path listed in the string at the top of inputFed.cpp. This will run that script when the federation is running. At each time step, the inputFed finds the condition and passes that to the SAPOPFed through a CondEvent interaction. The SAPOPFed reads from this and updates its SANet. It then replans and each step produces a small graphical visual of what must be accomplished in the environment. The SANet is a modified version of the demo scenario .In it, the UAV's and Ground forces are trying to stop the Vehicle with the IED from reaching the destination. TestScript1 shows the use of ground forces. TestScript2 uses the UAVs to carry out the mission with missiles. The Graph shows the last step that occurred. The Action to be completed next is green. The Conditions to be satisfied next is in orange. 

To run:
From cygwin run the script you either modified for the Environment Variables and Path above or just from:   
  -%C2WTROOT%\generated\scripts\demoSAPOP

When the SAPOPFed comes up, it will ask which goals to plan for in the scenario. This is where the planner wants to know what you want to accomplish
in the domain. So for the demo, say you want to plan for 2 goals. The first is 2012 with a utility of 10. The second is 2014 with a utility of 10.
 

Then the input fed asks for a character and a return so it can send the next event. The planning is done when the graphic visualization comes up. 

 

After being satisfied with the current visualization, go back to the inputFed and enter another character. This controls when the next event is sent from the script. Continue until the inputFed says that the script has ended.

	